package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/15.
 */
@HttpInlet(Conn.GAINS_CHART)
public class ChartsDatasGet extends BaseAsyGet<ChartsDatasGet.ChartsDatasEntity> {

    public String sid, type;

    public ChartsDatasGet(AsyCallBack<ChartsDatasEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected ChartsDatasEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            JSONArray arrayDate = object.optJSONArray("list");

            ChartsDatasEntity chartsDatasEntity = new ChartsDatasEntity();

            for (int i = 0; i < arrayDate.length(); i++) {

                JSONObject objectDatas = arrayDate.optJSONObject(i);

                chartsDatasEntity.chartsDates.add(objectDatas.optString("time"));
                chartsDatasEntity.chartsNums.add(objectDatas.optInt("num"));

            }

            return chartsDatasEntity;

        }

        return null;
    }

    public static class ChartsDatasEntity {

        public List<String> chartsDates = new ArrayList<>();
        public List<Integer> chartsNums = new ArrayList<>();

    }




}
